package com.controladores.controlvehicular;

import java.util.Calendar;

import android.R.layout;
import android.os.Bundle;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Intent;
import android.graphics.Typeface;
import android.support.v4.view.ViewPager.LayoutParams;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
//import android.widget.Toast;

public class RegistroTarjeta extends Activity implements android.view.View.OnClickListener{
	protected TextView fuenteRT;
	EditText editableHora1 ,editableHora2, editableHora3, editableHora4, editableHora5, editableHora6, editableHora7,
	editableHora8, editableHora9, editableHora10, editableHora11,editableHora12;
	EditText editableFecha1, editableFecha2, editableFecha3, editableFecha4, editableFecha5, editableFecha6, editableFecha7,
	editableFecha8,editableFecha9, editableFecha10, editableFecha11, editableFecha12;
	int horas, minutos; 
	int a, m, d;
	Button btn; 
	/*@Override
	
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	        Bundle savedInstanceState) {
	    View view = inflater.inflate(R.layout.main, container);
	    editText = (EditText) view.findViewById(R.id.nombreTxt);
	    editText.requestFocus();
	    getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
	    return view;
	}*/

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_registro_tarjeta);

		editableHora1=(EditText) findViewById(R.id.EditText14);
		editableHora1.setOnClickListener(this);	
		editableHora2=(EditText) findViewById(R.id.EditTextprueba);
		editableHora2.setOnClickListener(this);
		editableHora3=(EditText) findViewById(R.id.EditText15);
		editableHora3.setOnClickListener(this);
		editableHora4=(EditText) findViewById(R.id.EditText16);
		editableHora4.setOnClickListener(this);
		editableHora5=(EditText) findViewById(R.id.EditText17);
		editableHora5.setOnClickListener(this);
		editableHora6=(EditText) findViewById(R.id.EditText18);
		editableHora6.setOnClickListener(this);
		editableHora7=(EditText) findViewById(R.id.EditText19);
		editableHora7.setOnClickListener(this);
		editableHora8=(EditText) findViewById(R.id.EditText20);
		editableHora8.setOnClickListener(this);
		editableHora9=(EditText) findViewById(R.id.EditText21);
		editableHora9.setOnClickListener(this);
		editableHora10=(EditText) findViewById(R.id.EditText22);
		editableHora10.setOnClickListener(this);
		editableHora11=(EditText) findViewById(R.id.EditText23);
		editableHora11.setOnClickListener(this);
		editableHora12=(EditText) findViewById(R.id.EditText24);
		editableHora12.setOnClickListener(this);
		
		editableFecha1=(EditText) findViewById(R.id.EditText04);
		editableFecha1.setOnClickListener(this);
		editableFecha2=(EditText) findViewById(R.id.editText1);
		editableFecha2.setOnClickListener(this);
		editableFecha3=(EditText) findViewById(R.id.EditText01);
		editableFecha3.setOnClickListener(this);
		editableFecha4=(EditText) findViewById(R.id.EditText02);
		editableFecha4.setOnClickListener(this);
		editableFecha5=(EditText) findViewById(R.id.EditText03);
		editableFecha5.setOnClickListener(this);
		editableFecha6=(EditText) findViewById(R.id.EditText06);
		editableFecha6.setOnClickListener(this);
		editableFecha7=(EditText) findViewById(R.id.EditText07);
		editableFecha7.setOnClickListener(this);
		editableFecha8=(EditText) findViewById(R.id.EditText08);
		editableFecha8.setOnClickListener(this);
		editableFecha9=(EditText) findViewById(R.id.EditText09);
		editableFecha9.setOnClickListener(this);
		editableFecha10=(EditText) findViewById(R.id.EditText10);
		editableFecha10.setOnClickListener(this);
		editableFecha11=(EditText) findViewById(R.id.EditText11);
		editableFecha11.setOnClickListener(this);
		editableFecha12=(EditText) findViewById(R.id.EditText12);
		editableFecha12.setOnClickListener(this);
		
		btn=(Button) findViewById(R.id.button3);
		btn.setOnClickListener(this);
		
		fuenteRT = (TextView)findViewById(R.id.tRegistroTarjeta); 
		Typeface tipofuenteRT = Typeface.createFromAsset(getAssets(), "inkedgod.ttf");
		fuenteRT.setTypeface(tipofuenteRT);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_registro_tarjeta, menu);
		return true;
	}
	public boolean onOptionsItemSelected(MenuItem item){
		switch(item.getItemId()){
		case R.id.mInformacionVehiculod:
			Intent aInformacionVehiculo = new Intent(RegistroTarjeta.this, InformacionVehiculo.class);
			startActivity(aInformacionVehiculo);
			break;
			
		case R.id.mAyudad:
			Intent aAyuda = new Intent(RegistroTarjeta.this, Ayuda.class);
			startActivity(aAyuda);
			break;		
		}
		return super.onOptionsItemSelected(item);
	}
	
		
		
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
		OnTimeSetListener mtpd1 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				editableHora1.setText("               "+
				view.getCurrentHour()+ ":"+view.getCurrentMinute());
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();
				
			}
		};
		
		OnTimeSetListener mtpd2 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora2.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();
				
			}
		};
		OnTimeSetListener mtpd3 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora3.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();
				
			}
		};
		OnTimeSetListener mtpd4 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora4.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();
				
			}
		};
		OnTimeSetListener mtpd5 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora5.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();			
			}
		};
		OnTimeSetListener mtpd6 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora6.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();			
			}
		};
		OnTimeSetListener mtpd7 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora7.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();			
			}
		};
		OnTimeSetListener mtpd8 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora8.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();			
			}
		};
		OnTimeSetListener mtpd9 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora9.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();			
			}
		};
		OnTimeSetListener mtpd10 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora10.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();			
			}
		};
		OnTimeSetListener mtpd11 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora11.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();			
			}
		};
		OnTimeSetListener mtpd12 = new OnTimeSetListener() {					 
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				//int diez =9;
				editableHora12.setText("               "+
				view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				//Toast.makeText(getBaseContext(), "El tiempo es: "+
				//view.getCurrentHour()+ ":"+view.getCurrentMinute(), Toast.LENGTH_LONG).show();			
			}
		};
		
		
		OnTimeSetListener mbtnprueba = new OnTimeSetListener() {
			
			@Override
			public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
				// TODO Auto-generated method stub
				btn.setText("               "+
						view.getCurrentHour()+ ":"+(view.getCurrentMinute()));
				
			}
		};
		// metodos fechas
		
		OnDateSetListener mdpd1 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha1.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd2 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha2.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd3 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha3.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd4 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha4.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd5 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha5.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd6 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha6.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd7 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha7.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd8 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha8.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd9 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha9.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd10 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 1;
				editableFecha10.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd11 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 11;
				editableFecha11.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		OnDateSetListener mdpd12 = new OnDateSetListener() {
			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear,
					int dayOfMonth) {
				// TODO Auto-generated method stub
				a = year;
				m = monthOfYear;
				d = dayOfMonth;
				int uno = 12;
				editableFecha12.setText( "        "+a+"/"+(m+uno)+"/"+d);
				Toast.makeText(getBaseContext(), "El dia seleccionado es "+ a+"/"+(m+uno)+"/"+d, Toast.LENGTH_LONG).show(); 
			}
		};
		
		
		Calendar calendario = Calendar.getInstance();
		a = calendario.get(Calendar.YEAR); 
		m = calendario.get(calendario.MONTH);
		d = calendario.get(Calendar.DAY_OF_MONTH);
		
		
		switch (v.getId()) {
		
		case R.id.EditText14:
			TimePickerDialog tpd1 = new TimePickerDialog(this, mtpd1, horas, minutos, true);
			tpd1.show();
			//editable.setText(editable.setText());
			//Intent aRegistroVehiculo = new Intent(RegistroTarjeta.this,InformacionVehiculo.class);
			//startActivity(aRegistroVehiculo);
			break;
		case R.id.button3:
			TimePickerDialog btnprueba = new TimePickerDialog(this, mbtnprueba, horas, minutos, true);
			btnprueba.show();
			
		case R.id.EditTextprueba:
			TimePickerDialog tpd2 = new TimePickerDialog(this, mtpd2, horas, minutos, true);
			tpd2.show();
			break;
		case R.id.EditText15:
			TimePickerDialog tpd3 = new TimePickerDialog(this, mtpd3, horas, minutos, true);
			tpd3.show();
			break;
		case R.id.EditText16:
			TimePickerDialog tpd4 = new TimePickerDialog(this, mtpd4, horas, minutos, true);
			tpd4.show();
			break;
		case R.id.EditText17:
			TimePickerDialog tpd5 = new TimePickerDialog(this, mtpd5, horas, minutos, true);
			tpd5.show();
			break;
		case R.id.EditText18:
			TimePickerDialog tpd6 = new TimePickerDialog(this, mtpd6, horas, minutos, true);
			tpd6.show();
			break;
		case R.id.EditText19:
			TimePickerDialog tpd7 = new TimePickerDialog(this, mtpd7, horas, minutos, true);
			tpd7.show();
			break;
		case R.id.EditText20:
			TimePickerDialog tpd8 = new TimePickerDialog(this, mtpd8, horas, minutos, true);
			tpd8.show();
			break;
		case R.id.EditText21:
			TimePickerDialog tpd9 = new TimePickerDialog(this, mtpd9, horas, minutos, true);
			tpd9.show();
			break;
		case R.id.EditText22:
			TimePickerDialog tpd10 = new TimePickerDialog(this, mtpd10, horas, minutos, true);
			tpd10.show();
			break;
		case R.id.EditText23:
			TimePickerDialog tpd11 = new TimePickerDialog(this, mtpd11, horas, minutos, true);
			tpd11.show();
			break;
		case R.id.EditText24:
			TimePickerDialog tpd12 = new TimePickerDialog(this, mtpd12, horas, minutos, true);
			tpd12.show();
			break;
			
		case R.id.EditText04:
			DatePickerDialog dpd1 = new DatePickerDialog(this, mdpd1, a, m, d);
			dpd1.show();
			break;
		case R.id.editText1:
			DatePickerDialog dpd2 = new DatePickerDialog(this, mdpd2, a, m, d);
			dpd2.show();
			break;
		case R.id.EditText01:
			DatePickerDialog dpd3 = new DatePickerDialog(this, mdpd3, a, m, d);
			dpd3.show();
			break;	
		case R.id.EditText02:
			DatePickerDialog dpd4 = new DatePickerDialog(this, mdpd4, a, m, d);
			dpd4.show();
			break;	
		case R.id.EditText03:
			DatePickerDialog dpd5 = new DatePickerDialog(this, mdpd5, a, m, d);
			dpd5.show();
			break;
		case R.id.EditText06:
			DatePickerDialog dpd6 = new DatePickerDialog(this, mdpd6, a, m, d);
			dpd6.show();
			break;
		case R.id.EditText07:
			DatePickerDialog dpd7 = new DatePickerDialog(this, mdpd7, a, m, d);
			dpd7.show();
			break;
		case R.id.EditText08:
			DatePickerDialog dpd8 = new DatePickerDialog(this, mdpd8, a, m, d);
			dpd8.show();
			break;
		case R.id.EditText09:
			DatePickerDialog dpd9 = new DatePickerDialog(this, mdpd9, a, m, d);
			dpd9.show();
			break;
		case R.id.EditText10:
			DatePickerDialog dpd10 = new DatePickerDialog(this, mdpd10, a, m, d);
			dpd10.show();
			break;
		case R.id.EditText11:
			DatePickerDialog dpd11 = new DatePickerDialog(this, mdpd11, a, m, d);
			dpd11.show();
			break;
		case R.id.EditText12:
			DatePickerDialog dpd12 = new DatePickerDialog(this, mdpd12, a, m, d);
			dpd12.show();
			break;
		default:
			break;
		
			
		}
		
		
	//	DatePickerDialog dpd = new DatePickerDialog(this, mdpd, a, m, d);
	//dpd.show();
	}

}
